//
//  EC2.h
//  cTypica
//
//  Created by David Kavanagh on 10/14/08.
//  Copyright 2008 directThought. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AWSQueryConnection.h"
#import "ImageDescription.h"
#import "ReservationDescription.h"
#import "Instance.h"
#import "VolumeInfo.h"
#import "AttachmentInfo.h"
#import "ConsoleInfo.h"
#import "SnapshotInfo.h"
#import "GroupInfo.h"
#import "IpPermission.h"
#import "AddressInfo.h"
#import "KeypairInfo.h"
#import "ZoneInfo.h"
#import "RegionInfo.h"
#import "LaunchConfiguration.h"
#import "BlockDeviceMapping.h"
#import "TerminatingInstancesDescription.h"

@protocol ImageDescriptionProtocol;
@protocol ReservationDescriptionProtocol;

@interface EC2 : AWSQueryConnection {
}

- (id)initWithAccessId:(NSString *)aId secretKey:(NSString *)sKey;

- (id)initWithAccessId:(NSString *)aId secretKey:(NSString *)sKey hostName:(NSString *)hName;

- (void)describeImages:(BOOL)all receiver:(id<ImageDescriptionProtocol>)receiver; // ImageDescriptionProtocol
- (void)describeInstances:(NSArray *)instanceIds receiver:(id<ReservationDescriptionProtocol>)receiver; // ReservationDescriptionProtocol
- (NSArray *)describeVolumes:(NSArray *)volumeIds;
- (NSArray *)describeSnapshots:(NSArray *)snapshotIds;
- (NSArray *)describeSecurityGroups:(NSArray *)groupNames;
- (NSArray *)describeAddresses:(NSArray *)addresses;
- (NSArray *)describeKeypairs:(NSArray *)keys;

- (void)runInstances:(LaunchConfiguration *)config receiver:(id<ReservationDescriptionProtocol>)receiver; // ReservationDescriptionProtocol
- (ConsoleInfo *)getConsoleOutput:(NSString *)instanceId;
- (NSArray *)rebootInstances:(NSArray *)instanceIds;
- (NSArray *)terminateInstances:(NSArray *)instanceIds;

- (NSString *)allocateAddress;
- (void)associateAddress:(NSString *)address instanceId:(NSString *)instanceId;
- (void)disassociateAddress:(NSString *)instanceId;
- (void)releaseAddress:(NSString *)address;

- (VolumeInfo *)createVolume:(NSString *)size snapshotId:(NSString *)snapId zoneName:(NSString *)zone;
- (void)deleteVolume:(NSString *)volumeId;
- (AttachmentInfo *)attachVolume:(NSString *)volumeId instanceId:(NSString *)instanceId device:(NSString *)device;
- (AttachmentInfo *)detachVolume:(NSString *)volumeId instanceId:(NSString *)instanceId device:(NSString *)device force:(Boolean)force;

- (SnapshotInfo *)createSnapshot:(NSString *)volumeId;
- (void)deleteSnapshot:(NSString *)snapshotId;

- (NSArray *)describeAvailabilityZones:(NSArray *)zones;
- (NSArray *)describeRegions:(NSArray *)regions;

@end

// for receiving messages about images
@protocol ImageDescriptionProtocol
@optional
- (void)startNewImageDescription;
@required
// This method must return true to keep receiving data
- (BOOL)imageDescriptionReady:(ImageDescription *)imageDesc;
@optional
- (void)endNewImageDescription;
@end

// for receiving messages about instances
@protocol ReservationDescriptionProtocol
@optional
- (void)startNewReservationDescription;
@required
// This method must return true to keep receiving data
- (BOOL)reservationDescriptionReady:(ReservationDescription *)resDesc;
@optional
- (void)endNewReservationDescription;
@end